﻿using System;
using System.Web;

namespace JQuery
{
    public static partial class Extensions
    {
        public static IHttpModule GetModule(this HttpContextBase oContext, string oName)
        {
            HttpApplication theApp = oContext.ApplicationInstance;// ?? System.Web.HttpContext.Current.ApplicationInstance;

            return theApp.Modules[oName];
        }
        /// <summary>
        /// Get the Resource Manager
        /// </summary>
        /// <param name="oContext">HttpContext</param>
        /// <returns></returns>
        //public static ResourceManager ResourceManager(this HttpContextBase oContext)
        //{
        //    return ((Modules.JQNModule)oContext.GetModule("JQNModule")).Manager;
        //}

        public static string BaseUri(this HttpContextBase oContext)
        {
            return String.Format("http{0}://{1}{2}",
                oContext.Request.IsSecureConnection ? "s" : "",
                oContext.Request.Url.DnsSafeHost,
                oContext.Request.Url.IsDefaultPort ? "" : ":" + oContext.Request.Url.Port.ToString());
        }
    }
}
